﻿<Window x:Class="ResourceBlender_Express.WinExport"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:loc="clr-namespace:ResourceBlender_Express"
    xmlns:validators="clr-namespace:ResourceBlender_Express.Validators"
    xmlns:props="clr-namespace:ResourceBlender_Express.Properties"
    loc:WindowService.EscapeClosesWindow="True" Loaded="Window_Loaded"
    Title="Export" WindowStartupLocation="CenterOwner"
    Height="500" Width="550" MinHeight="400" MinWidth="350" MaxHeight="550" MaxWidth="700"
    Style="{StaticResource {x:Type Window}}" Icon="/ResourceBlender-Express;component/Resources/images/resourceblender.ico" ResizeMode="CanResize">
    <Window.CommandBindings>
        <CommandBinding Command="loc:ResourceBlenderCommands.Browse" Executed="BrowseForFile" />
        <CommandBinding Command="loc:ResourceBlenderCommands.UpdateFilename" Executed="UpdateFilename" />
        <CommandBinding Command="loc:ResourceBlenderCommands.Export" Executed="Export" CanExecute="CanExecuteExport"  />
    </Window.CommandBindings>
    <Window.Resources>
        <props:Settings x:Key="settings" />
    </Window.Resources>
    <DockPanel Margin="6" LastChildFill="true" DataContext="{StaticResource settings}">
        <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" MinHeight="10" HorizontalAlignment="Right">
            <Button x:Name="btnExport" MinWidth="70" IsDefault="True" Command="loc:ResourceBlenderCommands.Export">Export</Button>
        </StackPanel>
        <StackPanel DockPanel.Dock="Top">
            <GroupBox Header="Format">
                <StackPanel>
                    <ListBox MinHeight="15" x:Name="lstType" Style="{StaticResource RadioListTemplate}" 
                             SelectedValuePath="Tag" SelectionChanged="lstType_SelectionChanged">
                        <ListBoxItem Tag="xml">XML Backup</ListBoxItem>
                        <ListBoxItem Tag="xmlxls">XML Spreadsheet</ListBoxItem>
                    </ListBox>
                    <CheckBox x:Name="chkZip" IsChecked="{Binding Path=Default.ZipOutput,Mode=TwoWay}"
                              Checked="UpdateFilename" Unchecked="UpdateFilename">Zip output</CheckBox>
                </StackPanel>
            </GroupBox>
            <GroupBox Header="Components to Export" Margin="2" MaxHeight="230">
                <TabControl DockPanel.Dock="Top" x:Name="tabWizard" DataContext="{StaticResource settings}" Background="Transparent" BorderThickness="0" SelectedIndex="0">
                    <TabItem Height="0" x:Name="tbXML">
                        <StackPanel>
                            <CheckBox x:Name="chkApplications" IsChecked="{Binding Path=Default.BackupApplications,Mode=TwoWay}">Applications</CheckBox>
                            <CheckBox x:Name="chkElements" IsChecked="{Binding Path=Default.BackupElements,Mode=TwoWay}">Elements</CheckBox>
                            <CheckBox x:Name="chkTemplates" IsChecked="{Binding Path=Default.BackupTemplates,Mode=TwoWay}">Templates</CheckBox>
                            <CheckBox x:Name="chkResources" IsChecked="{Binding Path=Default.BackupResources,Mode=TwoWay}">Resources</CheckBox>
                        </StackPanel>
                    </TabItem>
                    <TabItem Height="0" x:Name="tbXMLXLS">
                        <!-- app selector added from code-behind to maintain designer support-->
                    </TabItem>
                </TabControl>
            </GroupBox>
            <GroupBox Header="Save As">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Label Grid.Row="0" Grid.Column="0">Filename</Label>
                    <TextBox x:Name="txtFilename" Grid.Row="0" Grid.Column="1">
                        <Binding Path="Default.LastImportFile" Mode="TwoWay">
                            <Binding.ValidationRules>
                                <validators:StringValidationRule MinimumLength="0" ErrorMessage="Export path must be specified" />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox>

                    <Button Grid.Row="1" Grid.Column="1" Command="loc:ResourceBlenderCommands.Browse" HorizontalAlignment="Right">Browse...</Button>
                </Grid>
            </GroupBox>
        </StackPanel>
    </DockPanel>
</Window>
